import ini_op

def getCookies(cookies):
    cookie_key, kt, lj, jw, header_key1, header_key2, header_value1, header_value2 = ini_op.getinivalue('request_config', 'cookies', 'kt', 'lj', 'jw', 'header_key1', 'header_key2', 'header_value1', 'header_value2')
    cookie_list = [djlx.strip() for djlx in cookie_key.split('、')]
    rcookie = kt
    for cookie_key in cookie_list:
        for cookie in cookies:
            if cookie['name'] == cookie_key:
                rcookie = rcookie + cookie_key + '=' + cookie['value'] + lj
                break
    if len(lj) != 0:
        rcookie = rcookie[:-len(lj)] + jw
    else:
        rcookie = rcookie + jw
    header = {
        "Cookie": rcookie,
        header_key1: header_value1,
        header_key2: header_value2
    }
    return header